<template>
  <!-- 新闻列表 -->
  <div
    class="news-item"
    :style="{
      'box-shadow': showBoxShadow ? ' 0 2px 12px 0 rgba(0, 0, 0, 0.1)' : '',
    }"
  >
    <el-image
      :style="{ width: imageWidth, height: imageHeight }"
      class="news-cover"
      fit="cover"
      :src="newsItem.cover"
    ></el-image>
    <div class="news-content-ws" :style="`--imageWidth: ${imageWidth}`">
      <div class="news-title">
        {{ newsItem.title }}
      </div>
      <div class="news-content">
        {{ newsItem.describe }}
      </div>
    </div>
  </div>
</template>
<script>
export default {
  name: "skyNewsList",
  props: {
    imageWidth: {
      //新闻封面宽度
      type: String,
      default: "150px",
    },
    imageHeight: {
      //新闻封面高度
      type: String,
      default: "100px",
    },
    showBoxShadow: {
      // 阴影边框
      type: Boolean,
      default: true,
    },
    newsItem: {
      type: Object,
      default: () => {},
    },
  },
};
</script>

<style lang="less" scoped>
.news-item {
  width: 100%;
  display: flex;
  margin-bottom: 15px;
  padding: 15px;
  box-sizing: border-box;
  cursor: pointer;
  .news-cover {
    flex-shrink: 0;
    box-sizing: border-box;
    border-radius: 4px;
  }
  .news-content-ws {
    display: inline-block;
    width: calc(100% - var(--imageWidth));
    padding-left: 15px;
    box-sizing: border-box;
  }
  .news-title {
    width: 100%;
    font-size: 18px;
    font-weight: bold;
    line-height: 35px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    &:hover {
      text-decoration: underline;
    }
  }
  .news-content {
    font-size: 14px;
    line-height: 21px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }
}
</style>